/*
 * NxPSDetectCentroid.java
 *
 * Created on 8 de diciembre de 2007, 04:40 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package Behaviors;
import Behaviors.NxBehavior;
import Utils.*;

import javaclient3.*;
import javaclient3.structures.*;

/**
 *
 * @author nxbot
 */
public class NxPSDetectCentroid extends NxBehavior{
    Position2DInterface [] positions=null;
    
    
    /** Creates a new instance of NxPSDetectCentroid */
    public NxPSDetectCentroid(String name,Position2DInterface [] positions) {
        super(name);
        this.positions = positions;
    }
    
    public Vector2d Value(){
        Vector2d [] vectorPositions=new Vector2d[positions.length];
        for(int i=0;i<positions.length;i++){
            vectorPositions[i] = Position2DHelper.getPosition(positions[i]);
        }
        
        Vector2d average=Vector2d.averageVector(vectorPositions);
        
        //System.out.println("Average: "+average.toString());
        return average;
    }
}
